const { User } = require('../../model/user');
module.exports = async (req, res) => {
    // 用户页面标识
    req.app.locals.currentLink = 'user';

    // 获取到地址栏的id参数
    const { message, id } = req.query;
    if (id) {
        // 修改操作
        let userdata = await User.findOne({ _id: id });
        res.render('admin/user-edit', {
            userdata: userdata,
             message: message,
            link: '/admin/user-modify?id='+id,
            button: '修改',
            id:id
        });
    } else {
        // 添加操作
        res.render('admin/user-edit', {
            message: message,
            link: '/admin/user-edit',
            button:'添加'
        });
    }
    
}